//
// Created by Tony on 2024/7/30.
//

#ifndef RT_CODE_NATIVE_METHOD_TABLE_H
#define RT_CODE_NATIVE_METHOD_TABLE_H

#include "../rt_data/Frame.h"
#include <unordered_map>

namespace RtCode {

using std::unordered_map;
using NativeMethod = void (*)(RtData::Frame&);

class NativeMethodTable {
    unordered_map<string, NativeMethod> mMethodTable; // key: ${className}${methodName}

    static string buildKey(const string& className, const string& methodName);

public:
    NativeMethodTable() = default;

    void add(const string& className, const string& methodName, NativeMethod method);
    NativeMethod get(const string& className, const string& methodName);
};

} // namespace RtCode

#endif // RT_CODE_NATIVE_METHOD_TABLE_H
